package com.flute.icrawler.app.entity;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

import com.flute.icrawler.framework.autoadjust.FetchAdjuster.FetchStatus;

public class CrawlResult implements Serializable {

	private static final long serialVersionUID = -1487163347141170228L;

	/**
	 * 链接名
	 */
	private String url;

	private int id;

	/**
	 * 主机名
	 */
	private String hostName;

	/**
	 * http链接响应值
	 */
	private int fetchCode;

	/**
	 * 响应状态
	 */
	private FetchStatus fetchStatus;

	/**
	 * 链接内容类型
	 */
	private String contentType = "";

	/**
	 * 字符编码
	 */
	private String charSet = "";

	/**
	 * 链接内容
	 */
	private transient byte[] content = null;

	/**
	 * 链接中包含的图片地址
	 */
	private transient String[] imgs = null;

	/**
	 * 链接中包含的文件地址
	 */
	private transient String[] files = null;

	/**
	 * 文件保存的路径
	 */
	private String fileSavePath = "";

	/**
	 * 发起连接话费的时间
	 */
	private long fetchTime = 0;

	public String getHostName() {
		return hostName;
	}

	public void setHostName(String hostName) {
		this.hostName = hostName;
	}

	/**
	 * 内部处理状态
	 * 
	 * @return
	 */
	public FetchStatus getFetchStatus() {
		return fetchStatus;
	}

	/**
	 * 内部处理状态
	 * 
	 * @param fetchStatus
	 */
	public void setFetchStatus(FetchStatus fetchStatus) {
		this.fetchStatus = fetchStatus;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public String getCharSet() {
		return charSet;
	}

	public void setCharSet(String charSet) {
		this.charSet = charSet;
	}

	public byte[] getContent() {
		return content;
	}

	public void setContent(byte[] content) {
		this.content = content;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	/*
	 * 获取HashCode值
	 */
	public String getUrlHashCode() {
		return String.valueOf(content.hashCode());
	}

	public long getFetchTime() {
		return fetchTime;
	}

	public void setFetchTime(long fetchTime) {
		this.fetchTime = fetchTime;
	}

	public String[] getImgs() {
		return imgs;
	}

	public void setImgs(String[] imgs) {
		this.imgs = imgs;
	}

	public String getContentAsString() throws UnsupportedEncodingException {
		return new String(content, charSet);
	}

	/**
	 * http链接响应值
	 * 
	 * @return
	 */
	public int getFetchCode() {
		return fetchCode;
	}

	/**
	 * http链接响应值
	 * 
	 * @param fetchCode
	 */
	public void setFetchCode(int fetchCode) {
		this.fetchCode = fetchCode;
	}

	public String[] getFiles() {
		return files;
	}

	public void setFiles(String[] files) {
		this.files = files;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getFileSavePath() {
		return fileSavePath;
	}

	public void setFileSavePath(String fileSavePath) {
		this.fileSavePath = fileSavePath;
	}

}
